<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2016/9/9
 * Time: 15:35
 */
if (!defined('ACCESS')) {
    exit('Access denied.');
}

class AdminPayLog extends Base
{

    private static $table_name = 'payment_log';
    // 查询字段
    private static $columns = array('id', 'OrderID', 'MerchantID', 'TransNo', 'Currency', 'Amount', 'Version', 'BName', 'BEmail', 'BAddress', 'BCity', 'BState', 'BPostcode', 'BCountry', 'BPhone',
        'CardNumber', 'CardMonth', 'CardYear', 'CardCvv', 'URL', 'IP', 'UserAgent', 'AcceptLanguage', 'Products', 'RetCode', 'RetStatus', 'RetMsg', 'createtime', 'modifytime');

    public static function getTableName()
    {
        return self::$table_name;
    }


    public static function getLogByOrderSn($sn)
    {
        $condition = array('OrderID' => $sn);
        $db = self::__instance();
        $rt = $db->get(self::getTableName(), self::$columns, $condition);
        return $rt;
    }

    public static function getCountBySearch($search)
    {
        $db = self::__instance();
        $sql = "select count(*) as c from " . self::getTableName() . " $search";
        $rt = $db->query($sql)->fetch();
        if ($rt) {
            return $rt['c'];
        }
        return 0;
    }


    public static function getAllPayLogs($start = 0, $page_size = 20, $search)
    {
        $db = self::__instance();
        if ($search) {
            $con = $search;
        } else {
            $con = " WHERE 1=1 ";
        }
        $where = " $con ORDER BY createtime DESC LIMIT $start,$page_size";
        $result = $db->select(self::getTableName(), self::$columns, $where);
        return $result;
    }
}




